<%@page import="com.funtl.framework.web.map.BaseInfo"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<title><%=BaseInfo.PROJECT_NAME%> - 权限分栏管理</title>
<jsp:include page="/head.jsp" />
<script type="text/javascript">
	function add() {
		$("#dlg_manager").dialog("open");
		$("#fm_manager").form("clear");
	}
	
	function edit() {
    	var row = $("#dg_list").datagrid("getSelected");
    	if (row == null) {
    		dialog.info("请选择一条记录");
    	} else {
    		$("#dlg_manager").dialog("open");
    		$("#purview_column_id").val(row.id);
    		$("#purview_column_name").val(row.columnName);
    		$("#purview_column_no").val(row.columnNo);
    	}
    }
    
    function del() {
    	var row = $("#dg_list").datagrid("getSelected");
    	if (row == null) {
    		dialog.info("请选择一条记录");
    	} else {
    		dialog.confirm("确定要删除记录吗？", function() {
    			var data = {
    				"purviewColumn.id" : row.id
    			};
    			ajax.post("system/purview/column/ajax/delete", data, function(data) {
    				if (data.message == null || data.message.length == 0) {
    					$("#dg_list").datagrid("reload");
    					dialog.info("删除成功");
    				} else {
    					dialog.info(data.message);
    				}
    			});
    		});
    	}
    }
	
	var dlgManagerBtn = [{
        text:"保存",
        iconCls:"icon-ok",
        handler:function() {
        	if ($("#purview_column_id").val() == "") {
        		$("#fm_manager").attr("action", "system/purview/column/ajax/insert");
        	} else {
        		$("#fm_manager").attr("action", "system/purview/column/ajax/update");
        	}
        	
        	form.submit("fm_manager", function(data) {
				if (data.message == null || data.message.length == 0) {
					$("#fm_manager").form("clear");
					$("#dlg_manager").dialog("close");
					$("#dg_list").datagrid("reload");
					dialog.info("保存成功");
				} else {
					dialog.info(data.message);
				}
			});
        }
    },{
        text:"取消",
        iconCls:"icon-cancel",
        handler:function() {
        	$("#dlg_manager").dialog("close");
        }
    }];
</script>
</head>

<body>
	<table id="dg_list" class="easyui-datagrid" data-options="rownumbers:true,singleSelect:true,url:'system/purview/column/ajax/query',toolbar:'#dg_list_toolbar'">
  		<thead>
  			<tr>
  				<th data-options="field:'columnName'">栏目名称</th>
  				<th data-options="field:'columnNo'">排序序号</th>
  				<th data-options="field:'createName'">创建人</th>
  				<th data-options="field:'createDate', formatter:formatter.formatDateTime">创建日期</th>
  				<th data-options="field:'updateName'">修改人</th>
  				<th data-options="field:'updateDate', formatter:formatter.formatDateTime">修改日期</th>
  			</tr>
  		</thead>
  	</table>
  	<div id="dg_list_toolbar" style="padding:5px;height:auto">
   		<div style="margin-bottom:5px">
	  		<a class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="add();">新增</a> 
			<a class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="edit();">编辑</a> 
			<a class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="del();">删除</a>
		</div>
   	</div>
   	
   	<div id="dlg_manager" class="easyui-dialog" style="width:400px;height:auto;padding:10px" data-options="title:'信息管理',buttons:dlgManagerBtn,modal:true,closed:true">
   		<form id="fm_manager" method="post" action="">
   			<input id="purview_column_id" type="hidden" name="purviewColumn.id" />
   			<table align="center">
   				<tr>
	    			<td align="right">栏目名称：</td>
	    			<td><input id="purview_column_name" class="easyui-validatebox" type="text" name="purviewColumn.columnName" data-options="required:true"></input></td>
	    		</tr>
	    		<tr>
	    			<td align="right">排序序号：</td>
	    			<td><input id="purview_column_no" class="easyui-validatebox" type="text" name="purviewColumn.columnNo" data-options="required:true"></input></td>
	    		</tr>
   			</table>
   		</form>
   	</div>
</body>
</html>